Logo
Spacer News Wiki Features F.A.Q. Team members Screenshots Download Messageboard Bug tracker Submit files
Top divider

Lua SyncedCtrl

Contents

[edit] Resources

Spring.AddTeamResource

 ( number teamID, string "m" | "e", number amount ) -> nil

Spring.UseTeamResource

 ( number teamID, 
   string "m" | "e", number amount |
   { m = number amount, e = number amount}
 ) -> nil | boolean hadEnough

Spring.SetTeamResource

 ( number teamID, string res, number amount ) -> nil

 possible values for res are:
   "m"  = metal
   "e"  = energy
   "ms"  = metal storage
   "es"  = energy storage

Spring.SetTeamShareLevel

 ( number teamID, string "m" | "e", number amount ) -> nil


[edit] Unit Handling

Spring.CreateUnit

 ( string "defName",
   number x, number y, number z,
   (number facing | string "facing"),
   number teamID ) -> number unitID

 possible values for facing are:
   "s" | 0 = south
   "e" | 1 = east
   "n" | 2 = north
   "w" | 3 = west

Spring.DestroyUnit

 ( number unitID,
   [boolean selfd,]
   [boolean reclaimWreckage,]
   [number attackerID] ) -> nil

Spring.TransferUnit

 ( number unitID,
   numer newTeamID,
   boolean given ) -> nil


[edit] Unit Control

Spring.SetUnitCosts

 ( number unitID, { 
    [ buildTime  = number amount ],
    [ metalCost  = number amount ],
    [ energyCost = number amount ]
  } ) -> nil

Spring.SetUnitTooltip

 ( number unitID, string "tooltip" ) -> nil

Spring.SetUnitHealth

 ( number unitID,
   number health |
   { [ health   = number health ],
     [ capture  = number capture ],
     [ paralyze = number paralyze ],
     [ build    = number build ] }
 ) -> nil

Spring.SetUnitMaxHealth

 ( number unitID, number maxHealth ) -> nil

Spring.AddUnitDamage

 ( number unitID, number damage
   [, number paralyze = 0 [, number attackerID = -1 [, number weaponID = -1
     [, number impulse_x [, number impulse_y [, number impulse_z ]]] ]]] ) -> nil

Spring.SetUnitStockpile

 ( number unitID [, number stockpile [, number buildPercent ]]) -> nil

Spring.SetUnitExperience

 ( number unitID, number experience ) -> nil

Spring.SetUnitCloak

 ( number unitID,
   boolean cloaked | number scriptCloak,
   [ number decloakDistance | boolean decloakAbs ] ) -> nil
 
 If the 2nd argument is a number, the value works like this:
  1:=normal cloak
  2:=for free cloak (cost no E)
  3:=for free + no decloaking (except the unit is stunned)
  4>=ultimative cloak (no ecost, no decloaking, no stunned decloak)
 The decloak distance is only changed if the 3th argument is a number or a boolean.
  If the boolean is false it takes the default decloak distance for that unitdef,
  if the boolean is true it takes the absolute value of it.

Spring.SetUnitStealth

 ( number unitID, boolean stealth ) -> nil

Spring.SetUnitLineage

 ( number unitID, number teamID [, boolean isRoot] ) -> nil

Spring.SetUnitNeutral

 ( number unitID, boolean neutral ) -> nil

Spring.SetUnitTarget

 ( number unitID,
   number enemyUnitID | number x, number y, number z,
   [ boolean dgun = false ] ) -> nil

Spring.SetUnitAlwaysVisible

 ( number unitID, boolean alwaysVisible ) -> nil

Spring.SetUnitBlocking

 ( number unitID, boolean noBlock) -> nil

Spring.SetUnitMetalExtraction

 ( number unitID, number depth [,number range] ) -> nil

Spring.SetUnitBuildSpeed

 ( number builderID,
   number buildSpeed, [ number repairSpeed [, number reclaimSpeed
 [,number resurrectSpeed [, number captureSpeed [, number terraformSpeed ]] ]]] ) -> nil

Spring.SetUnitShieldState

 ( number unitID, boolean enabled [, number power] ) -> nil

Spring.SetUnitWeaponState

 ( number unitID, number weaponNum, table states ) -> nil
 format of the states table:
   {
     ["reloadstate" = number value,]
     ["reloadtime"  = number value,]
     ["accuracy"    = number value,]
     ["sprayangle"  = number value,]
     ["range"       = number value,]
     ["projectilespeed" = number value,]
   }
 

Spring.SetUnitTravel

 ( number unitID, number travel [, number travelPeriod] ) -> nil

Spring.SetUnitMoveGoal used by default commands to get in build-,attackrange etc.

 ( number unitID, number x, number y, number z,
   [, number radius = 0 [, number speed = unit->maxSpeed * 2 ] ] ) -> nil

Spring.SetUnitPhysics

 ( number unitID,
   number posx, number posy, number posz,
   number velx, number vely, number velz,
   number rotx, number roty, number rotz,
 ) -> nil

Spring.SetUnitPosition

 ( number unitID, number x, number z [, boolean alwaysAboveSea] ) -> nil

Spring.SetUnitVelocity

 ( number unitID, number velx, number vely, number velz ) -> nil

Spring.SetUnitRotation

 ( number unitID, number rotx, number roty, number rotz ) -> nil

Spring.AddUnitImpulse

 ( number unitID, number x, number y, number z ) -> nil

[edit] Unit Ressourcing

Spring.SetUnitResourcing

 ( number unitID,
   string res, number amount |
   { res = number amount, ... }
 ) -> nil

 possible values for res are: "[u|c][u|m][m|e]"
      unconditional | conditional
                use | make
              metal | energy

Spring.AddUnitResource

 ( number unitID, string "m" | "e", number amount ) -> nil

Spring.UseUnitResource

 ( number unitID, string "m" | "e", number amount ) -> nil

[edit] Feature Handling

Spring.CreateFeature

 (  string "defName", number x, number y, number z
  [,number heading [, number AllyTeamID ]] ) -> number featureID

Spring.DestroyFeature

 ( number featureID ) -> nil

Spring.TransferFeature

 ( number featureID, number AllyTeamID ) -> nil


[edit] Feature Control

Spring.SetFeatureHealth

 ( number featureID, number health) -> nil

Spring.SetFeatureReclaim

 ( number featureID, number reclaimLeft) -> nil

Spring.SetFeatureResurrect

 ( number featureID, string "UnitDefName?" [, number facing | string "facing" ] ) -> nil

 possible string values for facing are:
   "s"  = south
   "e"  = east
   "n"  = north
   "w"  = west

Spring.SetFeaturePosition

 ( number featureID, number x, number y, number z ) -> nil

Spring.SetFeatureDirection

 ( number featureID, number x, number y, number z ) -> nil

Spring.SetFeatureNoSelect

 ( number featureID, boolean noSelect ) -> nil


Spring.RemoveBuildingDecal

 ( number unitID ) -> nil


[edit] Lua to COB

Spring.CallCOBScript

 ( number unitID, number funcID | string funcName, number retArgs, COBArg1, COBArg2, ... )
   -> nil | number returnValue, number retArg1, number retArg2, ...

Spring.CallCOBScriptCB

 ( number unitID, number funcID | string funcName, number retArgs, COBArg1, COBArg2, ... )
   -> nil | number returnValue, number CallbackData, number retArg1, number retArg2, ...

Spring.GetCOBScriptID

 ( number unitID, string funcName ) -> nil | number funcID

Spring.GetUnitCOBValue

 ( number unitID [, boolean splitData=false], number COBValue
   [, number param1 [,number param2 [, number param3 [, number param4 ] ] ] ] )
 -> number result | number result1, number result2

Spring.SetUnitCOBValue

 ( number unitID, number COBValue, number param1 [,number param2] ) -> nil

[edit] Give Order

Spring.GiveOrderToUnit

 ( number unitID,
   number cmdID,
   params = {number, etc...},
   options = {"alt", "ctrl", "shift", "right"} ) -> nil

Spring.GiveOrderToUnitMap

 ( unitMap = { [unitID] = dontCare, etc... },
   number cmdID,
   params = {number, etc...},
   options = {"alt", "ctrl", "shift", "right"} ) -> nil

Spring.GiveOrderToUnitArray

 ( unitArray = { [1] = unitID, etc... },
   number cmdID,
   params = {number, etc...},
   options = {"alt", "ctrl", "shift", "right"} ) -> nil

Spring.GiveOrderArrayToUnitMap

 ( unitMap = { [number unitID] = dontCare, etc... },
   orderArray = {
     { number cmdID,
       params = {number, etc...},
       options = {"alt", "ctrl", "shift", "right"}
     }, ..
   }
 ) -> nil

Spring.GiveOrderArrayToUnitArray

 ( unitArray = { [1] = number unitID, etc... },
   orderArray = {
     { number cmdID,
       params = {number, etc...},
       options = {"alt", "ctrl", "shift", "right"}
     }, ..
   }
 ) -> nil

[edit] Heightmap

Spring.LevelHeightMap

 ( number x1, number z1 [, number x2, number z2], number height ) -> nil

Spring.AdjustHeightMap (heightmap[x][z] += height;)

 ( number x1, number z1 [, number x2, number z2], number height ) -> nil

Spring.RevertHeightMap

 ( number x1, number z1 [, number x2, number z2], number origFactor ) -> nil

[edit] Command Descriptions

Doesn't work in unsynced code.

Spring.EditUnitCmdDesc

 ( number unitID, number cmdDescID, table cmdArray ) -> nil

 structure of cmdArray:
 {
   [ id          = int ],
   [ type        = int ],
   [ name        = string ],
   [ action      = string ],
   [ tooltip     = string ],
   [ texture     = string ],
   [ cursor      = string ],
   [ hidden      = boolean ],
   [ disabled    = boolean ],
   [ showUnique  = boolean ],
   [ onlyTexture = boolean ],
   [ params      = { string = string, ... } ]
 }

Spring.InsertUnitCmdDesc

 ( number unitID [, number cmdDescID ] , table cmdArray ) -> nil

Spring.RemoveUnitCmdDesc

 ( number unitID [, number cmdDescID ] ) -> nil

[edit] Other

Spring.SetNoPause

 ( boolean noPause ) -> nil

Spring.SetUnitToFeature

 ( boolean tofeature ) -> nil

Spring.SetExperienceGrade

 ( number expGrade
  [, number ExpPowerScale [, number ExpHealthScale [, number ExpReloadScale ]]] ) -> nil
 expGrade defines how often UnitExperience() will be called,
  it is based on the following equation:
    (int) [exp/(exp+1)] / expGrade
  If this integer differs from the one before the experience change
  it will call UnitExperience().
 Also those 3 last params are only available in .cheat
 

Retrieved from "http://spring.clan-sy.com/wiki/Lua_SyncedCtrl"

This page has been accessed 1,029 times. This page was last modified 22:49, 18 March 2008.